<template>
<div id='wrap'>
    <div id="RegisterBox">
        <div><span>账 号：</span><input type="text" placeholder="请输入账号" v-model="user"></div>
        <div><span>密 码：</span><input type="text" placeholder="请输入密码" v-model="pass"></div>
        <button @click="Login">登录</button>
        <button @click="toRegister">注册</button>
    </div>
</div>
</template>

<script lang='ts'>
export default {
name: 'LoginView',
}
</script>

<script lang='ts' setup>
import router from '@/router';
import { ref } from 'vue'
const user=ref('')
const pass=ref('')
const Login=()=>{
    const item=localStorage.getItem('token')
    if(item!==null){
        const array=JSON.parse(item)
        if(user.value=='' || pass.value==''){
            alert('账号密码不能为空')
        }else if(user.value==pass.value){
            alert('账号和密码不能相同')
        }else if(user.value==array.user && pass.value==array.pass){
            router.push('/')
        }else{
            alert('出现未知错误,请联系管理员1942693391')
        }
    }else{
        alert('账号密码不存在')
    }
}
const toRegister=()=>{
router.push('/RegsisterView')
}
</script>

<style scoped lang='scss'>
#RegisterBox{
position: fixed;
top: 40%;
left: 50%;
transform: translate(-50%,-50%);
width: 30rem;
height: auto;
justify-content: center;
align-items: center;
background-color: rgba(255, 255, 255, 0.2);
backdrop-filter: blur(15px);
border-radius: 20px;
padding: 30px;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
div{
    width: 100%;
    height: 4rem;
    margin-top: 5px;
    span{
    color: #7b7b7b;
    display: inline-block;
    text-align: center;
    line-height: 4rem;
    width: 10rem;
    }
    input{
    color: #7b7b7b;
    border: none;
    outline: none;
    height: 3rem;
    padding-left: 2rem;
    border-radius: 99999999px;
    width: calc(100% - 13rem);
    background-color: #f1f2f3;
    }
}
button{
    margin: 2rem 2rem;
}
}
</style>
